// 获取所有文集
import pool from '@/server/db'
import { RowDataPacket } from 'mysql2'

export default defineEventHandler(async () => {
  // 查询所有文集
  try {
    const [rows] = await pool.execute('SELECT * FROM `notebooks`')
    if ((rows as RowDataPacket[]).length < 1) {
      return r('查询所有文集失败')
    }
    return r('查询所有文集成功', 1, rows)
  } catch (error) {
    return r('所有文集查询失败:' + error)
  }
})
